﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsController_TM_User : clsConnect
    {
        private clsConnect cls = new clsConnect();

        #region[Get-Data]
        public DataTable BindGridUser()
        {
            return cls.BindGridData("sp_TM_Users");
        }
        public DataTable BindGridUserDetail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TM_Users_Detail_Edit", "@Users_ID", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertUser(clsTMUserProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@RolesID", data.RolesID);
            cls.AddParameter("@UserName", data.UserName);
            cls.AddParameter("@Passwords", data.Passwords);
            cls.AddParameter("@IDUnit", data.IDUnit);
            cls.AddParameter("@IdMember", data.IdMember);
            cls.AddParameter("@Note", data.Note);
            cls.AddParameter("@QLKD", data.QLKD);
            cls.AddParameter("@IDWarehouse", data.IDWarehouse);
            cls.AddParameter("@bitSys", data.bitSys);
            cls.ExecuteNonQuery("sp_TM_Users_Insert");
            return true;
        }
        public bool UpdateUser(clsTMUserProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Users_ID", data.Users_ID);
            cls.AddParameter("@RolesID", data.RolesID);
            cls.AddParameter("@UserName", data.UserName);
            cls.AddParameter("@Passwords", data.Passwords);
            cls.AddParameter("@IDUnit", data.IDUnit);
            cls.AddParameter("@IdMember", data.IdMember);
            cls.AddParameter("@Note", data.Note);
            cls.AddParameter("@QLKD", data.QLKD);
            cls.AddParameter("@IDWarehouse", data.IDWarehouse);
            cls.AddParameter("@bitSys", data.bitSys);
            cls.ExecuteNonQuery("sp_TM_Users_Update");
            return true;
        }
        public bool UpdateStatusUser(clsTMUserProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Users_ID", data.Users_ID);
            cls.AddParameter("@bitSys", data.bitSys);
            cls.ExecuteNonQuery("sp_TM_Users_Update_StatusUser");
            return true;
        }
        public bool DeleteUser(int id)
        {
            cls.Delete("sp_TM_Users_Delete", "@Users_ID", id);
            return true;
        }
        #endregion
    }
}
